import type { cardData } from '@/types/card'
import type { OrderListParams, OrderListResult } from '@/types/order'
import { http } from '@/utils/http'

export const createOrder = (data:orderInfo) => {
  return http<string>({
    method: 'POST',
    url: 'order/order/createOrder',
    data,
  })
}
export type orderInfo = {
  goodList: cardData[]
  selectType: number
  adr: addressInfo
  totalPrice: number
  OrderId: string
  userId: string
}


 type addressInfo = {
  id: string
  receiver: string
  phone: string
  provinceCode: number
  cityCode: number
  countyCode: number
  detailAddress: string
  isDefault: number
  fullLocation: string
  userId: string
  createTime: string
}


export const getOrder = (id:string) => {
  return http<orderResInfo>({
    method: 'GET',
    url: 'order/order/getOrder',
    data:{
      id
    },
  })
}

export type orderResInfo = {
  id: string
  orderState: number
  orderType: number
  userId: string
  orderTotalPrice: number
  createTime: Date
  adrId: string
  endTime: number
  createTimeStr: string
  osOrderValues: []
}

// private Long id;
// private Integer orderState;
// private Integer orderType;
// private Long userId;
// private Double orderTotalPrice;
// private Date createTime;
// private Long adrId;
// @TableField(exist = false)
// private Long endTime;
// @TableField(exist = false)
// private String createTimeStr;
// //    @TableField(exist = false)
// //    private List<GoodsMemberDtos> GoodsMemberDtosList;
// @TableField(exist = false)
// private List<OsOrderValue> osOrderValues;
/** 订单状态枚举 */
export enum OrderStateEnum {
  /** 待付款 */
  DaiFuKuan = 0,
  /** 待发货 */
  DaiFaHuo = 1,
  /** 待收货 */
  DaiShouHuo = 3,
  /** 待评价 */
  DaiPingJia = 4,
  /** 已完成 */
  YiWanCheng = 5,
  /** 已取消 */
  YiQuXiao = 2,
}

/** 订单状态列表 */
export const orderStateList: orderStateListStype= [
  { id: 0, text: '待付款' },
  { id: 1, text: '待发货' },
  { id: 2, text: '已取消' },
  { id: 3, text: '待收货' },
  { id: 4, text: '待评价' },
  { id: 5, text: '已完成' },
  { id: 6, text: '已取消' },
]

type orderStateListStype = orderStateListValueStype[]
type orderStateListValueStype = {id: number, text: string}


/**
 * 获取订单列表
 * @param data orderState 订单状态
 */
export const getOrderListApi = (data: OrderListParams) => {
  return http<OrderListResult>({
    method: 'GET',
    url: `order/order/getOrderList`,
    data,
  })
}

